package com.lecture.service.impl;

import java.util.List;

import com.lecture.service.MessageService;
import com.lecture.hibernate.pojo.MessageboxDAO;
import com.lecture.hibernate.pojo.Messagebox;
import com.lecture.hibernate.pojo.Student;
import com.lecture.hibernate.pojo.Teacher;
import com.lecture.view.builder.MessageBuilder;
import com.lecture.util.DateUtils;
import com.lecture.service.AccountService;
import com.lecture.hibernate.pojo.Account;
import com.lecture.view.bean.NavigationResults;
public class MessageServiceImpl implements MessageService {
	private MessageboxDAO messageBoxDA0;
	//private AccountService accountService;
	public MessageboxDAO getMessageBoxDAO()
	{
		return this.messageBoxDA0;
	}
	public void setMessageboxDAO(MessageboxDAO dao)
	{
		this.messageBoxDA0 = dao;
	}
	public String saveMessageBox(Messagebox msg)
	{
		messageBoxDA0.save(msg);
		return NavigationResults.SUCCESS;
	}
	public List<Messagebox> findMessageboxByTeacher(Teacher teacher) throws Exception
	{
		Messagebox msg = new Messagebox();
		msg.setTeacher(teacher);
		List<Messagebox> list = messageBoxDA0.findByExample(msg);
		return list;
	}
	public List<Messagebox> findMessageboxByStudent(Student student) throws Exception
	{
		Messagebox msg = new Messagebox();
		msg.setStudent(student);
		List<Messagebox> list = messageBoxDA0.findByExample(msg);
		return list;
	}
	public boolean updateMessageBox(Messagebox msg)
	{
		messageBoxDA0.merge(msg);
		return true;
	}
}
